package algocasts;

public class P21_maxSumOfSubArray {
    public int maxSumOfSubArray(int[] nums) {
        int max = Integer.MIN_VALUE;
        int cur = 0;
        for (int num : nums) {
            cur = cur <= 0 ? num : cur + num;
            max = Math.max(cur, max);
        }
        return max;
    }
}
